package cn.caplike.demo.repository.design.pattern.visitor.example;

import cn.caplike.demo.repository.design.pattern.visitor.example.element.Engineer;
import cn.caplike.demo.repository.design.pattern.visitor.example.element.Manager;
import cn.caplike.demo.repository.design.pattern.visitor.example.element.Staff;
import cn.caplike.demo.repository.design.pattern.visitor.example.visitor.Visitor;

import java.util.LinkedList;
import java.util.List;

// 员工业务报表类
public class BusinessReport {

    private final List<Staff> staffList = new LinkedList<>();

    public BusinessReport() {
        staffList.add(new Manager("经理-A"));
        staffList.add(new Engineer("工程师-A"));
        staffList.add(new Engineer("工程师-B"));
        staffList.add(new Engineer("工程师-C"));
        staffList.add(new Manager("经理-B"));
        staffList.add(new Engineer("工程师-D"));
    }

    /**
     * 为访问者展示报表
     *
     * @param visitor 具体的访问者: {@link cn.caplike.demo.repository.design.pattern.visitor.example.visitor.CEOVisitor CEO} or {@link cn.caplike.demo.repository.design.pattern.visitor.example.visitor.CTOVisitor CTO}
     */
    public void showReport(Visitor visitor) {
        for (Staff staff : staffList) {
            staff.accept(visitor);
        }
    }
}
